package day0804;

import java.io.*;
import java.util.Scanner;

/**
 * @author 杰哥不要啦~
 * @date 2021/8/4
 */
public class zuoye080401 {
    public static void main(String[] args) throws IOException {
        /*
        键盘录入数据源路径和目的地路径，分别使用【普通字符流】和【字符缓冲流的特殊功能】完成对指定文件的复制
        数据源： d:\a.txt
        目的地： d:\b.txt
        就将a.txt文件的数据复制到b.txt中
         */
        //d1();
        d2();
    }

    private static void d2() throws IOException {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入路径");
        BufferedReader br = new BufferedReader(new FileReader(sc.next()));
        System.out.println("请输入目的地路径");
        BufferedWriter bw = new BufferedWriter(new FileWriter(sc.next()));
        String a;
        while ((a = br.readLine())!= null){
            bw.write(a);
        }
        br.close();
        bw.close();

    }

    private static void d1() throws IOException {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入路径");
        FileReader fr = new FileReader(sc.next());
        System.out.println("请输入目的地路径");
        FileWriter fw = new FileWriter(sc.next());
        char[] ca = new char[1024];
        int a;
        while ((a = (fr.read(ca))) != -1){
            fw.write(ca,0,a);
        }
        fr.close();
        fw.close();
    }
}
